# Copyright 2003 Brian Gerkey
# Distributed under the terms of the GNU General Public License v2

inherit eutils

DESCRIPTION="One hell of a robot device server"
SRC_URI="mirror://sourceforge/playerstage/player-2.0.2.tar.bz2"
HOMEPAGE="http://playerstage.sourceforge.net"
S="${WORKDIR}/player-2.0.2"

KEYWORDS="~amd64 sparc x86"
SLOT="0"
LICENSE="GPL-2"
IUSE="doc python gazebo sphinx2 v4l ieee1394 opencv-cvs fixedtones howl ssl
sphinx2 wifi"

DEPEND=">=sci-libs/gsl-1.3
        python? ( >=dev-lang/python-2.2 dev-lang/swig media-libs/jpeg )
        gazebo? ( >=sci-misc/gazebo-0.5 )
        doc? ( app-doc/doxygen )
		opencv-cvs? ( media-libs/opencv-cvs )
		ieee1394? ( media-libs/libdc1394 )
		fixedtones? ( =sci-libs/fftw-2.1.5-r1 )
		howl? ( >=net-misc/howl-0.9.6 )
		ssl? ( dev-libs/openssl )
		sphinx2? ( app-accessibility/sphinx2 )
		>=sys-apps/sed-4"

src_unpack() {
	unpack ${A}
	cd ${S}
	epatch ${FILESDIR}/player-sphinx2.patch

	sed -i 's#$(prefix)/src/player#$(datadir)/player#g' ${S}/examples/plugins/exampledriver/Makefile.am
	sed -i 's#$(prefix)/src/player#$(datadir)/player#g' ${S}/examples/plugins/exampledriver/Makefile.in
	sed -i 's#$(prefix)/src/player#$(datadir)/player#g' ${S}/examples/plugins/multidriver/Makefile.am
	sed -i 's#$(prefix)/src/player#$(datadir)/player#g' ${S}/examples/plugins/multidriver/Makefile.in
}

src_compile() {
	econf \
        `use_enable python gazebo` \
		`use_enable ieee1394 camera1394` \
		`use_enable fixedtones` \
		`use_enable wifi aodv` \
		`use_enable wifi iwspy` \
		`use_enable wifi linuxwifi` \
		`use_enable ssl wavefront` \
		`use_enable howl service_adv_mdns` \
		`use_enable libplayerc-py sphinx2` \
		--enable-rflex \
		--enable-vfh \
		--enable-amcl \
		--enable-microstrain \
		|| die 
	emake -j1 || die 
	if use doc; then
		emake -C ${S}/doc doc
	fi
}

src_install() {
	einstall || die
	insinto /usr/include/player
	doins ${S}/server/error.h
	dodoc AUTHORS ChangeLog
	if use doc; then
		docinto html
		dohtml -a html,gif,css,ico,php,png doc/player/* 
	fi
}
